import { Node, Shape } from "@antv/x6";
import { nextId } from '../utils';
import { defaultPortGroup } from './_default';
import StartEventIcon from '../icons/StartEvent.svg';

export default class StartEvent extends Shape.Circle{
  private static default:Node.Metadata = {
    width: 40,
    height: 40,
    markup: [
      { tagName: 'circle', selector: 'body' },
      { tagName: 'image', selector: 'img' },
      { tagName: 'text', selector: 'label' },
    ],
    attrs: {
      body: {
        strokeWidth: 2,
        stroke: '#5F95FF',
        fill: '#FFF',
      },
      img: {
        x: 6,
        y: 6,
        width: 16,
        height: 16,
        'xlink:href': StartEventIcon
      },
      label: {
        fontSize: 12,
        fill: '#262626',
      },
    },
    ports: {
      groups: {
        top: { ...defaultPortGroup, position: "top" },
        right: { ...defaultPortGroup, position: "right" },
        bottom: { ...defaultPortGroup, position: "bottom" },
        left: { ...defaultPortGroup, position: "left" }
      },
      items: [
        { id: "P0_0", group: "top" },
        { id: "P1_0", group: "right" },
        { id: "P2_0", group: "bottom" },
        { id: "P3_0", group: "left" },
      ],
    }
  }
  private static complement = (metadata: Node.Metadata={}):Node.Metadata=>{
    metadata.id = metadata.id || nextId();
    return Object.assign({},StartEvent.default,metadata);
  }

  constructor(metadata: Node.Metadata={}){
    super(StartEvent.complement(metadata));
  }

}